using System;
using System.Text;
using Microsoft.Practices.RecipeFramework;
using System.ComponentModel.Design;

namespace SPALM.SharePointSoftwareFactory.Library.ValueProviders
{
  public class VisualStudioCreateSolutionName : ValueProvider
  {
    public override bool OnBeginRecipe(object currentValue, out object newValue)
    {
      if (currentValue != null)
      {
        // Do not assign a new value, and return false to flag that 
        // we don't want the current value to be changed.
        newValue = null;
        return false;
      }

      IDictionaryService dictionaryService = (IDictionaryService)this.GetService(typeof(IDictionaryService));
      try
      {
        string solutionName = dictionaryService.GetValue("SolutionName").ToString();
        solutionName = System.Text.RegularExpressions.Regex.Replace(solutionName, @"[^\w\.@-]", string.Empty);
        //solutionName.Replace(" ", "_");
        newValue = solutionName;
        return true;
      }
      catch (Exception)
      {
       
      }

      newValue = "Defaultname";
      return true;
    }
  }
}
